package com.ruoyi.ade.llm.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class ChatRequest {

    public static final String ROLE_SYSTEM = "system";
    public static final String ROLE_USER = "user";

    private String model;
    private ArrayList<Message> messages;
    private boolean stream = false;
    private Map<String,Object> options;


    public ChatRequest(String model, String systemMessage, String userMessage){
        this.model = model;
        messages = new ArrayList<>();
        messages.add(Message.systemMessage(systemMessage));
        messages.add(Message.userMessage(userMessage));
        options = new HashMap<>();
        options.put("temperature",0.1);
    }

//    public ChatRequest(String model, String userMessage){
//        this.model = model;
//        messages = new ArrayList<>();
//        messages.add(Message.userMessage(userMessage));
//        options = new HashMap<>();
//        options.put("temperature",0.1);
//    }
//
//
//    public ChatRequest(String model, ArrayList<Message> messages) {
//        this.model = model;
//        this.messages = messages;
//        options = new HashMap<>();
//        options.put("temperature",0.1);
//    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public ArrayList<Message> getMessages() {
        return messages;
    }

    public void setMessages(ArrayList<Message> messages) {
        this.messages = messages;
    }

    public boolean isStream() {
        return stream;
    }

    public void setStream(boolean stream) {
        this.stream = stream;
    }

    public Map<String, Object> getOptions() {
        return options;
    }

    public void setOptions(Map<String, Object> options) {
        this.options = options;
    }

    public static class Message{
        private String role;
        private String content;

        public Message(String role, String content){
            this.role = role;
            this.content = content;
        }
        public static Message systemMessage(String content){
            Message m = new Message(ROLE_SYSTEM,content);
            return m;
        }

        public static Message userMessage(String content){
            Message m = new Message(ROLE_USER,content);
            return m;
        }




        public String getRole() {
            return role;
        }

        public void setRole(String role) {
            this.role = role;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }
    }

}
